﻿@using CleanArchitecture.Core.Helper
@using CleanArchitecture.Infrastructure.Entities
@using CleanArchitecture.Infrastructure.Models.Business.Columns
@inject CleanArchitecture.Infrastructure.Entities.Settings.NewsSettings newsSettings;
@inject CleanArchitecture.Infrastructure.Entities.Settings.BlogSettings blogSettings;

@model ColumnItemModel
@{
    Layout = "_BackendLayout";
    ViewData["Title"] = ViewBag.PageTitle as string;
    var AvailableColumnTypes = ViewBag.AvailableColumnTypes as IList<SelectListItem> ?? null;
    var AvailableLanguages = ViewBag.AvailableLanguages as IList<SelectListItem> ?? null;
    var AvailableUrlTarget = ViewBag.AvailableUrlTarget as IList<SelectListItem> ?? null;
    var AvailablLayoutType = ViewBag.AvailablLayoutType as IList<SelectListItem> ?? null;
    var AvailableListLayout = ViewBag.AvailableListLayout as IList<SelectListItem> ?? null;
    var AvailableDetailLayout = ViewBag.AvailableDetailLayout as IList<SelectListItem> ?? null;
}
@section csslinks {
    <link rel="stylesheet" type="text/css" href="~/lib/jQueryTagsInput/dist/jquery.tagsinput.min.css" />
    <link rel="stylesheet" type="text/css" href="~/lib/messagebar/dist/jquery.messagebar.min.css" />
}
@section cssstyles {
    <style type="text/css">
        body {
            margin: 5px !important;
            display: flex;
            flex: auto;
            flex-direction: column;
            min-height: 0;
            background: #f0f2f5;
        }

        .layui-tab-title {
            padding-left: 20px;
        }

        .layui-form-switch {
            margin-top: 6px;
            height: 25px;
        }

        .layui-input-inline {
            width: 320px !important;
        }

        .layui-form-label {
            width: 130px !important;
        }

        .layui-input-block {
            margin-left: 130px !important;
        }

        .layui-slider-input {
            top: 0 !important;
        }

        .levelSlider,
        .orderSlider {
            padding-top: 15px;
        }

        .layui-upload-list img {
            max-width: 360px;
        }
    </style>
}
<div class="layui-container" style="background-color: #fff;">
    <form class="layui-form" action="">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">必填配置</li>
                <li>页面配置</li>
                <li>SEO配置</li>
            </ul>

            <div class="layui-tab-content">
                <!--必填配置-->
                <div class="layui-tab-item layui-show">
                    <input class="layui-hide" type="text" name="@Model.nameof(m => m.Id)" value="@Model.Id" />
                    <input class="layui-hide" type="text" name="@Model.nameof(m => m.IsActive)" value="@Model.IsActive" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.ParentId))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.ParentId)" value="@Model.ParentId" class="layui-hide" />
                            <div id="parentcolumn" class="xmselect"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.LanguageName))</label>
                        <div class="layui-input-inline">
                            <select asp-for="LanguageId" asp-items="@AvailableLanguages" lay-verify="required" lay-filter="LanguageSelect">
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.ColumnType))</label>
                        <div class="layui-input-inline">
                            <select asp-for="ColumnType" asp-items="@AvailableColumnTypes" lay-verify="required" lay-filter="ColumnTypeSelect">
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.Level))</label>
                        <div class="layui-input-inline">
                            <div id="levelSlider" class="levelSlider"></div>
                            <input type="text" class="layui-hide" name="@Model.nameof(m => m.Level)" value="@Model.Level" />
                        </div>
                        <div class="layui-form-mid layui-word-aux">系统根据栏目层次自动设置</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.Name))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.Name)" value="@Model.Name" lay-verify="required" placeholder="请选输入栏目名称" autocomplete="off" class="layui-input" />
                        </div>
                        <div class="layui-form-mid layui-word-aux">不超过20字</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.SubTitle))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.SubTitle)" value="@Model.SubTitle" placeholder="请选输入副标题名称" autocomplete="off" class="layui-input" />
                        </div>
                        <div class="layui-form-mid layui-word-aux">不超过20字</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.LayoutType))</label>
                        <div class="layui-input-inline">
                            <select asp-for="LayoutType" asp-items="@AvailablLayoutType" lay-verify="required" lay-filter="LayoutTypeSelect">
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.LayoutListTemplate))</label>
                        <div class="layui-input-inline">
                            <select asp-for="LayoutListTemplate" asp-items="@AvailableListLayout" lay-verify="required" lay-filter="LayoutListSelect">
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.LayoutDetailTemplate))</label>
                        <div class="layui-input-inline">
                            <select asp-for="LayoutDetailTemplate" asp-items="@AvailableDetailLayout" lay-verify="required" lay-filter="LayoutDetailSelect">
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.IsDisplay))</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="@Model.nameof(m => m.IsDisplay)" value="@Model.IsDisplay" lay-skin="switch" lay-text="ON|OFF" lay-filter="switchIsDisplay" @if (Model.IsDisplay == EntityEnumConfig.YesorNo.YES) { <text> checked</text> } />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.UrlRoute))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.UrlRoute)" value="@Model.UrlRoute" placeholder="请选输入导航地址" autocomplete="off" class="layui-input" />
                        </div>
                        <div class="layui-form-mid layui-word-aux">如不输入，则由系统规则默认生成</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.UrlTarget))</label>
                        <div class="layui-input-inline">
                            <select asp-for="UrlTarget" asp-items="@AvailableUrlTarget" lay-verify="required" lay-filter="UrlTargetSelect">
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.DisplayOrder))</label>
                        <div class="layui-input-inline">
                            <div id="orderSlider" class="orderSlider"></div>
                            <input type="text" class="layui-hide" name="@Model.nameof(m => m.DisplayOrder)" value="@Model.DisplayOrder" />
                        </div>
                    </div>
                </div>
                <!--页面配置-->
                <div class="layui-tab-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.PageSize))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.PageSize)" value="@Model.PageSize" placeholder="请选输入单页显示数量" autocomplete="off" class="layui-input" />
                        </div>
                        <div class="layui-form-mid layui-word-aux">如不输入，则设置为系统默认值</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.PageSizeOptions))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.PageSizeOptions)" value="@Model.PageSizeOptions" placeholder="请选输入单页可选显示数量" autocomplete="off" class="layui-input" />
                        </div>
                        <div class="layui-form-mid layui-word-aux">如不输入，则设置为系统默认值</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.IconImageUrl))</label>
                        <div class="layui-input-inline">
                            <div class="layui-upload iconimage">
                                <button type="button" class="layui-btn layui-btn-normal" id="iconimagebutton">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" />
                                </div>
                            </div>
                            <input type="text" class="layui-input layui-hide" name="@Model.nameof(m => m.IconImageUrl)" value="@Model.IconImageUrl" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.CoverImageUrl))</label>
                        <div class="layui-input-inline">
                            <div class="layui-upload coverimage">
                                <button type="button" class="layui-btn layui-btn-normal" id="coverimagebutton">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" />
                                </div>
                            </div>
                            <input type="text" class="layui-input layui-hide" name="@Model.nameof(m => m.CoverImageUrl)" value="@Model.CoverImageUrl" />
                        </div>
                    </div>
                </div>
                <!--SEO配置-->
                <div class="layui-tab-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.MetaTitle))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.MetaTitle)" value="@Model.MetaTitle" placeholder="请选输入Seo标题" autocomplete="off" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.MetaKeyWords))</label>
                        <div class="layui-input-inline">
                            <input type="text" name="@Model.nameof(m => m.MetaKeyWords)" value="@Model.MetaKeyWords" placeholder="请选输入Seo关键字" autocomplete="off" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">@(ReflectionExtensions.GetPropertyDisplayName<ColumnItemModel>(m => m.MetaDescription))</label>
                        <div class="layui-input-inline">
                            <textarea name="@Model.nameof(m => m.MetaDescription)" value="@Model.MetaDescription" placeholder="请输入内容" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div style="width: 100%; height: 50px; line-height: 50px;"></div> <!--占位符，防止底部固定提交栏遮挡最下层区域-->
        <div class="layui-form-item footerbar">
            @if (Model.Id == 0)
            {//只在新增模块时显示提示信息
                if ((newsSettings.Enabled && newsSettings.ColumnAuthorize) || (blogSettings.Enabled && blogSettings.ColumnAuthorize))
                {
                    <div class="messagebar messagebar-warning" style="width: 100%;">
                        <div class="container">
                            栏目权限设置功能已开启，新增栏目默认对所有用户都可编辑，请记得新增栏目后及时在栏目权限管理中设置用户权限。 点击关闭~
                            <button type="button" class="close" data-dismiss="message">&times;</button>
                        </div>
                    </div>
                }
            }
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="backendcolumnedit">立即提交</button>
            </div>
        </div>
    </form>
</div>

@section scripts{
    <script src="~/lib/xm-select/dist/xm-select.js" asp-append-version="true"></script>
    <script src="~/lib/jQueryTagsInput/dist/jquery.tagsinput.min.js"></script>
    <script src="~/lib/messagebar/dist/jquery.messagebar.min.js"></script>
    <script type="text/javascript">
    layui.use(['form', 'element', 'slider', 'notice', 'upload'], function () {
        var form = layui.form,
            element = layui.element,
            slider = layui.slider,
            uploader = layui.upload;
            notice = Util.notice !== null && Util.notice() !== null
                ? Util.notice() : layui.notice,
            lodash = _,
            levelSliderIns = null,
            $level = $("input[name=@Model.nameof(m => m.Level)]"),
            $currentColumnId = $("input[name=@Model.nameof(m => m.Id)]");
        var columntreeSelecter = xmSelect.render({
            el: '#parentcolumn',
            layVerify: 'required',
            layVerType: 'msg',
            autoRow: true,
            radio: true,
            clickClose: true,
            tree: {
                show: true,
                showFolderIcon: true,
                showLine: true,
                indent: 20,
                strict: false, //see https://gitee.com/maplemei/xm-select/issues/I15RD1
            },
            model: {
                label: {
                    type: 'block',
                    block: {
                        showCount: 1,//最大显示数量, 0:不限制
                        showIcon: false,//是否显示删除图标
                    }
		        }
	        },
            theme: {
		        color: '#0081ff',
	        },
            height: 'auto',
            data: [],
            on: function(data){
                var change = data.change,
                    selectedColumnId,
                    currentColumnId = parseInt($currentColumnId.val()),
                    $parentId = $("input[name=@Model.nameof(m => m.ParentId)]");
                if (change.length > 0) {
                    selectedColumnId = change[0].value;
                    if (currentColumnId > 0 && selectedColumnId === currentColumnId) {//新增栏目可以任意选择，已有栏目菜单不允许选择自已为父栏目
                        notice.error("栏目菜单不能选择自已做为父级栏目");
                        setLevel2origin();
                        return originParent;
                    }
                    $parentId.val(selectedColumnId);
                    //当切换所属父级菜单时，根据父节点深度设置本节点深度，否则栏目结构不对影响数据结构查询
                    var returnedColumn,
                        deepFind = function (arr, id) {
                            arr.forEach((item) => {
                                if (item.id === id) {
                                    returnedColumn = item;
                                    return item;
                                } else if (item.children.length > 0) {
                                    deepFind(item.children, id);
                                }
                            });
                        };
                    deepFind(columntreeSelecter.options.data, selectedColumnId);
                    if (typeof returnedColumn !== "undefined") {
                        levelSliderIns.setValue(returnedColumn.level + 1);
                        $level.val(returnedColumn.level + 1);
                    } else { //选择根节点时
                        levelSliderIns.setValue(1);
                        $level.val(1);
                    }
                }
	        }
        });
        //当发生错误时，修改深度为初始值
        var setLevel2origin = function () {
            var originParent = [@Model.ParentId],
                originLevel = @Model.Level;
            levelSliderIns.setValue(originLevel);
            $level.val(originLevel);
        };
        //更新父级栏目选择树
        var updateColumnTree = function (xmSelector, langid) {
            var index = layer.load(2, {time: 10*1000});
            httpapi.fetchGet('/api/backend/business/columnmanage/getcolumntree?languageid=' + langid).then(res => {
                layer.close(index);
                setLevel2origin();
                if (!httpapi.checkResponse(res)) {
                    //输入信息校验错误
                    notice.error(res.message);
                    xmSelector.update({
                        data: []
                    });
                }
                else {//Success
                    if (res.data === null) {
                        notice.error("Empty data!");
                        xmSelector.update({
                            data: []
                        });
                        return;
                    }
                    xmSelector.update({
                        data() {
                            var columnArr = [{ name: '根栏目', value: 0, level: 0, children: [] }];
                            return lodash.concat(columnArr, res.data);
                        }
                    });
                    var $parentId = $("input[name=@Model.nameof(m => m.ParentId)]"),
                        initVal = $parentId.val();
                    if (typeof initVal === 'string') initVal = parseInt(initVal);
                    var valArr = new Array();
                    valArr.push(initVal);
                    xmSelector.setValue(valArr);
                }
            }).catch(error => notice.error("对不起，出现未知错误，请您联系系统管理员！"));
        };
        var iconimageUploadIns = null,
            coverimageUploadIns = null;
        var initPageComponents = function () {
            //布局选择初始化设置
            //当布局类型为单页详情时，禁用列表布局选择
            if ($('#LayoutType option:selected').val() === "SingleDetailPage") {
                $("#LayoutListTemplate option:first").attr("selected", true);
                $("#LayoutListTemplate").attr("disabled", "disabled");
                form.render('select');
            }
            //滑动组件
            let $order = $("input[name=@Model.nameof(m => m.DisplayOrder)]"),
                langid = $('#LanguageId option:selected').val();
            levelSliderIns = slider.render({
                elem: '#levelSlider'
                , min: 0   //layui Bug : https://fly.layui.com/jie/45054/ setValue时为value * step + min
                , max: 50
                , input: true //输入框
                , theme: '#1E9FFF' //主题色
                , value: $level.val()
                //, change: function (value) { 关闭栏目深度赋值，在切换父栏目归属时根据纵深自动设置深度，否则影响栏目深度结构
                //    $level.val(value);
                //}
            });
            slider.render({
                elem: '#orderSlider'
                , min: 1
                , max: 50
                , input: true //输入框
                , theme: '#1E9FFF' //主题色
                , value: $order.val()
                , change: function (value) {
                    $order.val(value);
                }
            });
            //ColumnTree
            updateColumnTree(columntreeSelecter, langid);

            var $pagesizeoptions = $("input[name=@Model.nameof(m => m.PageSizeOptions)]"),
                $metakeywords = $("input[name=@Model.nameof(m => m.MetaKeyWords)]"),
                tagoptions = {
                    'width': 'auto',
                    'height': '45px',
                    'defaultText': 'add',
                    'removeWithBackspace': true,
                    'onAddTag': null
                };
            tagoptions.onAddTag = function (value) {
                if (!Util.isNumber(value)) {
                    $(this).removeTag(value);
                    return;
                }
                var tagslist = lodash.split($(this).val(), ',');
                if (tagslist.length > 5) {
                    notice.error("数量限制不应超过5个");
                    $(this).removeTag(value);
                    return;
                }
            };
            $pagesizeoptions.tagsInput(tagoptions);
            tagoptions.height = '100px';
            tagoptions.onAddTag = function (value) {
                var tagslist = lodash.split($(this).val(), ',');
                if (tagslist.length > 8) {
                    notice.error("数量限制不应超过8个");
                    $(this).removeTag(value);
                    return;
                }
            };
            $metakeywords.tagsInput(tagoptions);

            //IconImageUrl
            var iconImageUrl = "@Model.IconImageUrl";
            var coverImageUrl = "@Model.CoverImageUrl";
            var srcArr = null;
            if (iconImageUrl !== "") {
                srcArr = lodash.split(iconImageUrl, ';', 2);
                $("div.iconimage img").attr('src',srcArr[1]);
            }
            if (coverImageUrl !== "") {
                srcArr = lodash.split(coverImageUrl, ';', 2);
                 $("div.coverimage img").attr('src',srcArr[1]);
            }
            iconimageUploadIns = uploader.render({
                elem: '#iconimagebutton'
                , url: '/api/backend/business/columnimageupload'
                , accept: 'images'
                , acceptMime: 'image/*'
                , field: "ImageForm"
                , data: {
                    "Id": @Model.Id,
                    "ImageUrl": $("input[name=@Model.nameof(m => m.IconImageUrl)]").val()
                }
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $("div.iconimage img").attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    if (res.state && res.state === 200) {
                        notice.success(res.message);
                        $("input[name=@Model.nameof(m => m.IconImageUrl)]").val(res.data);
                    }
                    else notice.error(res.message);
                }
                , error: function () {
                    notice.error("上传图片失败，请联系系统管理");
                }
            });
            coverimageUploadIns = uploader.render({
                elem: '#coverimagebutton'
                , url: '/api/backend/business/columnimageupload'
                , accept: 'images'
                , acceptMime: 'image/*'
                , field: "ImageForm"
                , data: {
                    "Id": @Model.Id,
                    "ImageUrl": $("input[name=@Model.nameof(m => m.CoverImageUrl)]").val()
                }
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $("div.coverimage img").attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    if (res.state && res.state === 200) {
                        notice.success(res.message);
                        $("input[name=@Model.nameof(m => m.CoverImageUrl)]").val(res.data);
                    }
                    else notice.error(res.message);
                }
                , error: function () {
                    notice.error("上传图片失败，请联系系统管理");
                }
            });

            var $messageBar = $("div.messagebar");
            if ($messageBar.length > 0) {
                $messageBar.messageBar({ //https://github.com/audreyr/messagebar
                    slide: false
                });
            }
        };

        initPageComponents();
        $("#iconimagebutton").on("click", function () {
            iconimageUploadIns.reload({
                data: {
                    "Id": @Model.Id,
                    "ImageUrl": $("input[name=@Model.nameof(m => m.IconImageUrl)]").val()
                }
            });
        });
        $("#coverimagebutton").on("click", function () {
            coverimageUploadIns.reload({
                data: {
                    "Id": @Model.Id,
                    "ImageUrl": $("input[name=@Model.nameof(m => m.CoverImageUrl)]").val()
                }
            });
        });
        //语言切换选择查询对应ID的栏目菜单
        form.on('select(LanguageSelect)', function(data){
            updateColumnTree(columntreeSelecter, data.value);
        });
        //前端是否显示
        form.on('switch(switchIsDisplay)', function (data) {
            var value = data.elem.checked ? @((int)EntityEnumConfig.YesorNo.YES) : @((int)EntityEnumConfig.YesorNo.No);
            $(data.elem).val(value); //得到checkbox原始DOM对象
            form.render('checkbox', 'switchIsDisplay');
        });
        form.on('select(LayoutTypeSelect)', function (data) {
            if (data.value === "ArticleList" && $("#LayoutListTemplate").attr("disabled")) {
                $("#LayoutListTemplate").attr("disabled", false);
                form.render('select');
            } else if (data.value === "SingleDetailPage") {
                $("#LayoutListTemplate option:first").prop("selected", 'selected');
                $("#LayoutListTemplate").attr("disabled", "disabled");
                form.render('select');
            }
        });
        //提交保存
        form.on('submit(backendcolumnedit)', function (data) {
            var postData = data.field;
            var index = layer.load(2, { time: 10 * 1000 });
            if (postData.hasOwnProperty("select")) { //xm-select
                delete postData["select"];
            }
            if (postData.hasOwnProperty("ImageForm")) { //image upload
                delete postData["ImageForm"];
            }
            httpapi.fetchPost('/api/backend/business/columnmanage/edit', postData).then(res => {
                layer.close(index);
                if (!httpapi.checkResponse(res))
                    //输入信息校验错误
                    notice.error(res.message);
                else {//Success
                    notice.success(res.message);
                    Util.CloseMainWindow();
                }
            }).catch(error => {
                console.error(error);
                notice.error("对不起，出现未知错误，请您联系系统管理员！");
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
    </script>
}
